<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>个人代办事项管理系统</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" href="../../resources/styles/adminLTE/bower_components/bootstrap/dist/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet"
          href="../../resources/styles/adminLTE/bower_components/font-awesome/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="../../resources/styles/adminLTE/bower_components/Ionicons/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="../../resources/styles/adminLTE/dist/css/AdminLTE.min.css">
    <link rel="stylesheet" href="../../resources/styles/adminLTE/dist/css/skins/_all-skins.min.css">
    <!-- Morris chart -->
    <link rel="stylesheet" href="../../resources/styles/adminLTE/bower_components/morris.js/morris.css">
    <!-- jvectormap -->
    <link rel="stylesheet" href="../../resources/styles/adminLTE/bower_components/jvectormap/jquery-jvectormap.css">
    <!-- Date Picker -->
    <link rel="stylesheet"
          href="../../resources/styles/adminLTE/bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
    <!-- Daterange picker -->
    <link rel="stylesheet"
          href="../../resources/styles/adminLTE/bower_components/bootstrap-daterangepicker/daterangepicker.css">
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet"
          href="../../resources/styles/adminLTE/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
    <!--bootstrap-table 样式文件-->
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.12.1/bootstrap-table.min.css">
    <link rel="stylesheet" href="../../resources/styles/css/infomation.css">
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <!--bootstrap-table 文件-->
    <script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.12.1/bootstrap-table.min.js"></script>
    <!--bootstrap-table 文件-->
    <script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.12.1/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="../../resources/styles/js/infomation.js"></script>
    <!-- Google Font -->
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

    <header class="main-header">
        <!-- Logo -->
        <a href="index2.html" class="logo">
            <span class="logo-lg"><b>个人代办事项管理系统</b></span>
        </a>
        <nav class="navbar navbar-static-top">
            <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
                <span class="sr-only">收起导航栏</span>
            </a>
            <div class="navbar-custom-menu">
                <ul class="nav navbar-nav">
                    <li class="dropdown user user-menu">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <img src="../../resources/styles/adminLTE/dist/img/user2-160x160.jpg" class="user-image"
                                 alt="User Image">
                            欢迎您：<span id="hidden-xs"></span>
                        </a>

                    </li>

                </ul>
            </div>
        </nav>
    </header>

    <aside class="main-sidebar">

        <section class="sidebar">
            <ul class="sidebar-menu" data-widget="tree">
                <li class="header">导航栏</li>
                <li class="active treeview">
                    <a href="#">
                        <i class="fa fa-dashboard"></i> <span>系统管理</span>
                        <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
                    </a>
                    <ul class="treeview-menu">
                        <li><a href="/user/main"><i class="fa fa-circle-o"></i> 待办事项管理</a></li>
                        <li class="active"><a href="/user/infomation"><i class="fa fa-circle-o"></i> 个人信息维护</a></li>
                    </ul>
                </li>
            </ul>
        </section>

    </aside>


    <!--主面板开始-->
    <div class="content-wrapper">

        <section class="content-header">
            <h1>
                系统管理
                <small>个人信息维护</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
                <li class="active">个人信息维护</li>
            </ol>
        </section>

        <div style="background-color: white;margin: 20px 20px 20px 20px;text-align: center">

            <div class="div_title">
                <label class="title">基本信息:</label>

            </div>
            <HR>
            <form>
                <div class="form-group">
                    <label class="info_left">用户名:</label>
                    <label class="info_right" id="user_name">—</label>
                </div>
                <div class="form-group">
                    <label class="info_left">密码:</label>
                    <label class="info_right" id="pass_word" onclick="leftClick(this)">—</label>
                    <input class="left_input" style="display: none;width: 180px;margin-left: 20px"
                           onblur="leftBlur(this)">
                </div>
                <div class="form-group">
                    <label class="info_left">性别:</label>
                    <label class="info_right" id="sex" onclick="leftClick(this)">—</label>
                    <select class="left_input" style=";display: none;width: 179px;margin-left: 20px"
                            onblur="leftBlur(this)">
                        <option value="男">男</option>
                        <option value="女">女</option>
                    </select>

                </div>
                <div class="form-group">
                    <label class="info_left">年龄:</label>
                    <label class="info_right" id="age" onclick="leftClick(this)">—</label>
                    <input class="left_input" style="display: none;width: 180px;margin-left: 20px" onkeyup="this.value=this.value.replace(/[^\d]/g,'') "
                           onblur="leftBlur(this)">
                    <br>
                    <label id="age_verify" style="padding-left: 40px;color: red"></label>
                </div>

                <div class="form-group">
                    <label class="info_left">电话号码:</label>
                    <label class="info_right" id="phone" onclick="leftClick(this)">—</label>
                    <input class="left_input" style="display: none;width: 180px;margin-left: 20px"
                           onblur="leftBlur(this)">
                </div>

                <div class="div_title">
                    <label class="title">其他信息:</label>

                </div>
                <HR>
                <div class="form-group">
                    <label class="info_left">创建时间:</label>
                    <label class="info_right" id="creation_date">—</label>

                </div>
                <div class="form-group">
                    <label class="info_left">修改时间:</label>
                    <label class="info_right" id="lastUpadate_date">—</label>

                </div>
                <div class="form-group">
                    <label class="info_left">备注:</label>
                    <label class="info_right" id="comments" onclick="leftClick(this)">—</label>
                    <input class="left_input" style="display: none;width: 180px;margin-left: 20px"
                           onblur="leftBlur(this)">
                </div>


                <button type="submit" class="btn btn-default" onclick="updateInfomation(); return false">修改</button>
                <HR>
            </form>
        </div>


    </div>
    <!--主面板结束-->

    <script>



        $(function () {
            $.ajax({
                url: '/user/selectUserInfomationById',
                type: 'POST',
                async: true,
                dataType: 'json',
                success: function (data, textStatus, jqXHR) {
                    console.log(data);
                    document.getElementById('hidden-xs').innerText = data.userName;
                },
                error: function (xhr, textStatus) {
                    console.log('查询错误')

                },

            })

        });



        function leftClick(obj) {
            var div = $(obj);
            var par = div.next();
            div.css("display", "none");
            par.css("display", "");
            par.focus();
            console.log(div);
        };

        function leftBlur(obj) {
            var input = $(obj);
            var lab = input.prev();
            if ( input["0"].value!=""){
                lab["0"].innerHTML = input["0"].value;
            }
            input.css("display", "none");
            lab.css("display", "");
        }

        /*验证并传输修改的个人信息*/
        function updateInfomation() {
            var user_name = document.getElementById("user_name").innerText;
            var pass_word = document.getElementById("pass_word").innerText;
            var sex = document.getElementById("sex").innerText;
            var age = document.getElementById("age").innerText;
            var phone = document.getElementById("phone").innerText;
            var comments = document.getElementById("comments").innerText;

            if (sex == "男") {
                sex = "F";
            } else if(sex == "女")
            {
                sex = "M";
            }
            if (age < 1 || age > 200) {
                document.getElementById("age").click();
                document.getElementById("age_verify").innerText="请输入1-200之间";

                return false;
            }
            if (pass_word == "********") {
                pass_word == "";
            }


            $.ajax({
                url: '/user/updateInfomationByUserId',
                type: 'POST', //GET
                async: true,    //或false,是否异步
                data: {
                    "user_name": user_name,
                    "pass_word": pass_word,
                    "sex": sex,
                    "age": age,
                    "phone": phone,
                    "comments": comments,
                },
                dataType: 'json',    //返回的数据格式：json/xml/html/script/jsonp/text

                success: function (data, textStatus, jqXHR) {
                    if (data==1){
                        console.log("修改成功");
                        alert("修改成功");
                        location.reload();
                    }else {
                        alert("修改失败");
                        location.reload();
                    }


                },
                error: function (xhr, textStatus) {
                    console.log('错误')

                },

            })


        }
    </script>

</div>
<!-- jQuery 3 -->
<script src="../../resources/styles/adminLTE/bower_components/jquery/dist/jquery.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="../../resources/styles/adminLTE/bower_components/jquery-ui/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
    $.widget.bridge('uibutton', $.ui.button);
</script>
<!-- Bootstrap 3.3.7 -->
<script src="../../resources/styles/adminLTE/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Morris.js charts -->
<script src="../../resources/styles/adminLTE/bower_components/raphael/raphael.min.js"></script>
<script src="../../resources/styles/adminLTE/bower_components/morris.js/morris.min.js"></script>
<!-- Sparkline -->
<script src="../../resources/styles/adminLTE/bower_components/jquery-sparkline/dist/jquery.sparkline.min.js"></script>
<!-- jvectormap -->
<script src="../../resources/styles/adminLTE/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="../../resources/styles/adminLTE/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<!-- jQuery Knob Chart -->
<script src="../../resources/styles/adminLTE/bower_components/jquery-knob/dist/jquery.knob.min.js"></script>
<!-- daterangepicker -->
<script src="../../resources/styles/adminLTE/bower_components/moment/min/moment.min.js"></script>
<script src="../../resources/styles/adminLTE/bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
<!-- datepicker -->
<script src="../../resources/styles/adminLTE/bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
<!-- Bootstrap WYSIHTML5 -->
<script src="../../resources/styles/adminLTE/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<!-- Slimscroll -->
<script src="../../resources/styles/adminLTE/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="../../resources/styles/adminLTE/bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="../../resources/styles/adminLTE/dist/js/adminlte.min.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="../../resources/styles/adminLTE/dist/js/pages/dashboard.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../../resources/styles/adminLTE/dist/js/demo.js"></script>
</body>
</html>
